package pers.fjl.test.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import pers.fjl.common.constant.MessageConstant;
import pers.fjl.common.entity.QueryPageBean;
import pers.fjl.common.entity.Result;
import pers.fjl.common.po.Staff;
import pers.fjl.common.po.User;
import pers.fjl.common.validation.ValidGroup;
import pers.fjl.test.annotation.LoginRequired;
import pers.fjl.test.service.SalesService;
import pers.fjl.test.service.StaffService;

import javax.annotation.Resource;

/**
 * 员工管理模块
 *
 * @author fangjiale 2020年1月3日
 */

@Api(value = "后台管理员工模块", description = "后台管理员工模块的接口信息")
@RequestMapping("/manage/staff")
@RestController
@CrossOrigin
public class StaffController {
    @Resource
    private StaffService staffService;

    @LoginRequired
    @ApiOperation(value = "分页查询", notes = "返回分页数据")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        return new Result(true, MessageConstant.OK, "获取分页数据成功", staffService.findPage(queryPageBean));
    }

    @ApiOperation(value = "添加员工", notes = "添加员工")
    @PostMapping("/add")
    public Result add(@RequestBody Staff staff) {
        boolean flag = staffService.addStaff(staff);
        return new Result(flag, MessageConstant.OK);
    }

}
